<template>
  <nav-bar>
    <template #left>
      <div class="back" @click="backClick">
        <img src="~assets/img/common/back.svg"/>
      </div>
      </template>
    <template #center>
      <div class="nav-bar-title">
        <div v-for="(item, index) in navBarTitles" :class="{active: index == currentIndex}"
             class="title-item" @click="navBarItemClick(index)">
          <span>
            {{ item }}
          </span>
        </div>
      </div>
    </template>
  </nav-bar>
</template>

<script>
  import NavBar from 'components/common/navbar/NavBar'
  export default {
    name: "DetailNavBar",
    components: {
      NavBar
    },
    props: {
      navBarTitles: {
        type: Array,
        default() {
          return []
        }
      }
    },
    data() {
      return {
        currentIndex: 0
      }
    },
    methods: {
      backClick() {
        this.$router.back()
      },
      navBarItemClick(index) {
        this.$emit('navBarClick', index);
      }
    }
  }
</script>

<style scoped>

  .nav-bar-title {
    display: flex;
    font-size: 16px;
  }

  .title-item {
    flex: 1
  }

  .active {
    color: var(--color-high-text);
  }

  .back img {
    vertical-align:middle;
  }

</style>
